package com.qys.controller.user;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by fangc on 2019-10-20 14:44
 * 账号密码检查：
 *          若账号密码正确：则将username写入session
 */
@Controller
public class CheckController {
    @RequestMapping(path = "/check")
    public String check(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println(username + " - " + password);
        if ("123456".equals(password) && "admin".equals(username)){
            HttpSession session = request.getSession();
            session.setAttribute("user" , username);
            return "redirect:/file/upload";
        }
        return "redirect:/err";
    }
}
